using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;
using Utility;
namespace BUS
{
    public class tbDoanhNghiepBUS
    {
        public static void Insert(tbDoanhNghiep doanhnghiep)
        {
            tbDoanhNghiepDAL dnDAL = new tbDoanhNghiepDAL();
            dnDAL.Insert(doanhnghiep);
        }
        public static void Update(tbDoanhNghiep doanhnghiep)
        {
            tbDoanhNghiepDAL dnDAl = new tbDoanhNghiepDAL();
            dnDAl.Update(doanhnghiep);
        }
        public static void Delete(int iD)
        {
            tbDoanhNghiepDAL dnDAl = new tbDoanhNghiepDAL();
            dnDAl.Delete(iD);
        }
        public static tbDoanhNghiepCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbDoanhNghiepDAL dnDAL = new tbDoanhNghiepDAL();
            return dnDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDoanhNghiepCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDoanhNghiepDAL dnDAL = new tbDoanhNghiepDAL();
            return dnDAL.Get(cri.Criter, 0, 0, tbDoanhNghiepColumns.MaDN.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbDoanhNghiep GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbDoanhNghiepColumns.MaDN.ToString(), Condition.EQUAL, iD);
            tbDoanhNghiepDAL dnDAL = new tbDoanhNghiepDAL();
            tbDoanhNghiepCollection dnCollection = dnDAL.Get(cri.Criter, 0, 0, tbDoanhNghiepColumns.MaDN.ToString(), OrderDirection.ASC.ToString(), out total);
            if (dnCollection.Count > 0)
                return dnCollection[0];
            return null;
        }
        public static tbDoanhNghiepCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDoanhNghiepDAL dnDAL = new tbDoanhNghiepDAL();
            return dnDAL.Get(cri.Criter, 1, number, tbDoanhNghiepColumns.MaDN.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDoanhNghiepCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDoanhNghiepDAL dnDAL = new tbDoanhNghiepDAL();
            return dnDAL.Get(cri.Criter, 1, number, tbDoanhNghiepColumns.MaDN.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
